package com.xxx.grpc.server;

import io.grpc.Server;
import io.grpc.ServerBuilder;

import java.io.IOException;

/**
 * gRPC server端
 */
public class HelloServer {

    public static void main(String[] args) throws IOException, InterruptedException {
        // 创建Server，并绑定端口：50051
        Server server = ServerBuilder.forPort(50051)
                .addService(new HelloServiceImpl()) // 添加rpc接口实现类
                .build();
        // 启动server
        server.start();
        System.out.println("Server started at port 50051.");
        // 等待停止server
        server.awaitTermination();
    }

}